﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using BrokerBase.Lib.Policy;

namespace broker.duty.TK
{
    class Class1
    {
        public void Calc1(IPolicyPeriodActing ppa, IDutyActing da)
        {
            if (ppa.PolicyActing.Policy.PaymentPeriodLength>1 && ppa.IsAtPaymentPeriod && (ppa.Period +1) % 5==0)
            {
                da.Value = ppa.Amount * 0.5;
            }
        }

        public void Calc1(IPolicyPeriodActing ppa, IDutyActing da)
        {
            if (ppa.PolicyActing.Policy.PaymentPeriodLength > 1 && ppa.IsAtPaymentPeriod && ppa.Period>0)
            {
                da.Value = ppa.Amount * 0.02;
            }
        }

        public void Calc1(IPolicyPeriodActing ppa, IDutyActing da)
        {
            if (ppa.Period>0 && ppa.Age<=60)
            {
                da.Value = ppa.Amount * 0.1;
            }
            else if (ppa.Period > 0 && ppa.Age > 60 && ppa.Age <= 70)
            {
                da.Value = ppa.Amount * 0.2;
            }
        }

        public void Calc1(IPolicyPeriodActing ppa, IDutyActing da)
        {
            if (ppa.SchemePeriodActing.InsurantStates.Contains("身故"))
            {
                if (ppa.Age < 18)
                {
                    da.Value = ppa.TotalFee;
                }
                else if (ppa.Age >= 18 && ppa.Age <= 60)
                {
                    da.Value = ppa.TotalFee * 1.1;
                }
                else if (ppa.Age > 60 && ppa.Age <= 79)
                {
                    double x = ppa.PolicyActing.PeriodActings.Where(p => p.Age > 60 && p.Period<=ppa.Period).Sum(q => q.DutyActings.First(k => k.Duty.Name == "生存保险金").Value);

                    da.Value = ppa.Amount * 4 - x;
                }

                ppa.IsCurrentFinish = true;
            }
        }

        public void Calc1(IPolicyPeriodActing ppa, IDutyActing da)
        {
            if (ppa.SchemePeriodActing.InsurantStates.Contains("一次性领取") && ppa.Age==60)
            {
                da.Value = ppa.Amount * 20;
                ppa.IsCurrentFinish = true;
            }
        }

        public void Calc1(IPolicyPeriodActing ppa, IDutyActing da)
        {
            if (ppa.Period > 0)
            {
                double f = (double)ppa.SchemePeriodActing.SchemeActing.GetAuxConfigValue("分红率(预估)");

                da.Value = ppa.TotalFee * f;
            }
        }
    }
}
